
## Function 
MinMax <- function(inpath, outpath, para, fun = c("min", "max")) {
  output <- sapply(seq(inpath), function(i) {
    df <- read.table(inpath[i], header = T, sep = ",", stringsAsFactors = F)
    out <- switch(fun,
                  "min" = min(df[para], na.rm = T),
                  "max" = max(df[para], na.rm = T))
       
    }
          )
  write.table(output, outpath)
}
